**Replication Code: "Policy Feedback, Energy Equity, and Climate Justice: Can Existing Policies Improve Solar Access for Low- and Moderate Income Communities in the U.S.? 2024  PS: Political Science & Politics
** Aparajita Datta, University of Houston
**adatta3@central.uh.edu

**Include name of stata file in line 2
use "include name of stata file here"


// Recode party datafor state legislatures and governors as numeric 
generate gov_num=1
replace gov_num = 2 if Governor =="Ind"
replace gov_num=3 if Governor=="Dem"
generate lc_num=0
replace lc_num=1 if LegislativeControl=="Rep"
replace lc_num=2 if LegislativeControl=="Split"
replace lc_num=3 if LegislativeControl=="Dem"



// Add lables 
label variable Efficiency "Efficiency Policy"
label variable ElectricitySector  "Electricity Sector"
label variable Sunshine "Solar Potential"
label variable SolarShare "Share of Solar in Energy Mix"
label variable Bill "Average Annual Electricity Bill"
label variable InterestGroups "Renewable Energy Interest Groups"
label variable Poverty "Share of Population living below Federal Poverty Level"
label variable Spending "Federal Spending on Renewable Energy"
label variable gov_num "Governor's Party"
label variable lc_num "Legislative Control"
label variable NeighboringStatesEfficiency "Neighboring state- Efficiency Policies"
label variable NeighboringStatesElectricitySect "Neighboring states-  Electricity Portfolio Standards"


// Panel data regression - Unbalanced 
**For Table S4** 
xtset TimetoLMI

reg Event Efficiency ElectricitySector Sunshine SolarShare Bill InterestGroups Poverty Spending gov_num lc_num NeighboringStatesEfficiency NeighboringStatesElectricitySect

//install outreg2 if needed
ssc install outreg2


//random effects
xtreg Event Efficiency ElectricitySector Sunshine SolarShare Bill InterestGroups Poverty Spending gov_num lc_num NeighboringStatesEfficiency NeighboringStatesElectricitySect, re


//random effects, Swamy_Arora Estimator
xtreg Event Efficiency ElectricitySector Sunshine SolarShare Bill InterestGroups Poverty Spending gov_num lc_num NeighboringStatesEfficiency NeighboringStatesElectricitySect, re sa


outreg2 using TableS4.doc, label


/* Compare results with R code 
Cox Proportional Hazards Models
stset TimetoLMI

** For Table 1**
// Model 1
stcox Efficiency ElectricitySector, nohr 
outreg2 using Table1.doc

// Model 2
stcox NeighboringStatesEfficiency NeighboringStatesElectricitySect, nohr 
outreg2 using Table1.doc

//Model 3 
stcox stcox NeighboringStatesEfficiency NeighboringStatesElectricitySect Spending, nohr 
outreg2 using Table1.doc

//Full Model - Model 4
stcox Efficiency ElectricitySector Sunshine SolarShare Bill InterestGroups Poverty Spending gov_num lc_num NeighboringStatesEfficiency NeighboringStatesElectricitySect, nohr
outreg2 using Table1.doc

//As dummies 
**For Table S3** 
stcox i.Efficiency i.ElectricitySector Sunshine SolarShare Bill InterestGroups Poverty Spending gov_num lc_num NeighboringStatesEfficiency NeighboringStatesElectricitySect, nohr
outreg2 using TableS3.doc */ 
